<script setup>
defineProps({
  delete: {
    type: Boolean,
    dafault: false
  },
  delete1: {
    type: Boolean,
    dafault: true
  },
  putaway: {
    type: Boolean,
    dafault: false
  },
  soldout: {
    type: Boolean,
    dafault: false
  },
  recover: {
    type: Boolean,
    dafault: false
  },
  completely: {
    type: Boolean,
    dafault: false
  },
  create: {
    type: Boolean,
    dafault: true
  },
  export: {
    type: Boolean,
    dafault: false
  }
})

defineEmits([
  'create',
  'refresh',
  'deleteAll',
  'putaway',
  'soldout',
  'completely',
  'recover',
  'export'
])
</script>

<template>
  <div class="flex items-center justify-between mb-4">
    <div>
      <el-button type="primary" size="small" v-if="create" @click="$emit('create')">新增</el-button>
      <el-button type="warning" size="small" v-if="recover" @click="$emit('recover')"
        >恢复商品</el-button
      >
      <el-button type="danger" size="small" v-if="completely" @click="$emit('completely')"
        >彻底删除</el-button
      >

      <el-popconfirm
        title="是否要删除选择记录？"
        confirm-button-text="确认"
        cancel-button-text="取消"
        @confirm="$emit('deleteAll')"
      >
        <template #reference>
          <el-button type="danger" size="small" v-if="delete">批量删除</el-button>
        </template>
      </el-popconfirm>
      <el-button type="primary" size="small" text v-if="delete1">删除</el-button>
      <el-button size="small" v-if="putaway" @click="$emit('putaway')">上架</el-button>
      <el-button size="small" v-if="soldout" @click="$emit('soldout')">下架</el-button>
    </div>
    <div>
      <el-tooltip class="box-item" effect="dark" content="刷新数据" placement="top">
        <el-button text @click="$emit('refresh')">
          <el-icon :size="20"><RefreshRight /></el-icon>
        </el-button>
      </el-tooltip>

      <el-tooltip v-if="export" class="box-item" effect="dark" content="导出数据" placement="top">
        <el-button text @click="$emit('export')" style="margin-left: 0">
          <el-icon :size="20"><Download /></el-icon>
        </el-button>
      </el-tooltip>
    </div>
  </div>
</template>

<style></style>
